﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace asp.netWebFroms
{
    public class DbHelper
    {
        private static readonly string conSrting = "server = .; database = CMS; uid = sa; pwd = 123456;";

        public static DataTable GetDataTable(string sql)
        {
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql,conSrting);
            DataTable dataTable = new DataTable();
            sqlDataAdapter.Fill(dataTable);
            return dataTable;
            
        }

        public static int AddOrDeleteOrUp(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conSrting);
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
            sqlConnection.Open();
            var res = sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            return res;
        }

    }
}